<template>
  <div>
    <Loading v-show="this.$store.state.isLoading" />
    <div class="container">
      <Swipe :banners="banners"></Swipe>
      <List2 :obj="authorRecomd" @gotoContent="afterClick"></List2>
      <List2 :obj="serialUpdate" @gotoContent="afterClick"></List2>
      <List2 :obj="readBook" @gotoContent="afterClick"></List2>
      <List4 :obj="newBook" @gocontent="afterClick"></List4>
      <List4 :obj="Potential" @gocontent="afterClick"></List4>
      <List3 :obj="endHot" @gotoDetail="gotoDetail"></List3>
    </div>
  </div>
</template>

<script>
import { getStoreData } from "@/request/api";
import Swipe from "@/components/swipe";
import List2 from "@/components/List2";
import List3 from "@/components/List3";
import List4 from "@/components/List4";
export default {
  components: {
    Swipe,
    List2,
    List3,
    List4,
  },
  data() {
    return {
      //广告
      banners: [],
      //小编力荐
      authorRecomd: {
        list: [],
        name: "",
      },
      //连载追更
      serialUpdate: {
        list: [],
        name: "",
      },
      //完本畅读
      readBook: {
        list: [],
        name: "",
      },
      //新书独家
      newBook: {
        list: [],
        name: "",
      },
      //潜力IP
      Potential: {
        list: [],
        name: "",
      },
      //女生完结榜
      endHot: {
        list: [],
        name: "",
        more: {
          name: "",
          url: "",
        },
      },
    };
  },
  mounted() {
    getStoreData({
      type: this.$route.query.type,
      uuid: this.$route.query.uuid,
    }).then((res) => {
      if (res.resCode == 0) {
        let list = res.data.list;
        this.banners = list[0].banners;
        this.authorRecomd = list[1];
        this.serialUpdate = list[2];
        this.readBook = list[3];
        this.newBook = list[4];
        this.Potential = list[5];
        this.endHot = list[6];
      }
    });
  },
  methods: {
    afterClick(obj) {
      this.$router.push(
        "/content?source_uuid=" + obj.id + "&title=" + obj.title
      );
    },
    gotoDetail(id) {
      this.$router.push("/detail?sourceUuid=" + id);
    },
  },
};
</script>

<style>
</style>